package com.thoughtworks.biblioteca;

import java.util.Comparator;

/**
 * A comparator for sorting the movies by rating.
 */
public class RatingComparator implements Comparator<Movie> {

    private final int BEFORE = -1;
    private final int EQUAL = 1;
    private final int AFTER = 1;

    @Override
    public int compare(Movie movie1, Movie movie2) {
        if (movie1.getRating() < movie2.getRating())
            return BEFORE;
        else if (movie2.getRating() == movie2.getRating())
            return EQUAL;
        else
            return AFTER;
    }

}
